const Mock = require('mockjs')

const data = Mock.mock({
  'items|10': [{
    'id|+1': 0,//id int
    'name|+1': ['经理', '副经理', '助理', '秘书', '开发者', '技术顾问', '员工1', '员工2', '员工3', '员工4'],//部门名称 string
    note: '@csentence(5,10)',
    state: '@integer(0,1)'
  }]
})

module.exports = [
  {
    url: '/api/pos/getPos',
    type: 'get',
    response: config => {
      const items = data.items
      const { ids } = config.query
      const poslist = data.items.filter(item => ids.indexOf(item.id.toString()) >= 0)
      return {
        code: 20000,
        data: {
          total: items.length,
          items: poslist
        }
      }
    }
  },

  {
    url: '/api/pos/list',
    type: 'get',
    response: config => {
      const items = data.items
      const { ids } = config.query
      const poslist = data.items.filter(item => ids.indexOf(item.id.toString()) >= 0)
      return {
        code: 20000,
        data: {
          total: items.length,
          items: poslist
        }
      }
    }
  },

  {
    url: '/api/pos/deleteById',
    type: 'get',
    response: config => {
      const { id } = config.query
      data.items = data.items.filter(dep => dep.id != id)
      return {
        code: 20000,
        message: "删除成功"
      }
    }
  },
]
